<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var url = location.href;
    var search = location.search;  
    console.log(search);
    var data = {};

    if (search) {
        // var reg = /(\w+)=(\w+)/g;
        // var reg = /(\w+)=([^&]+)/g;
        // console.log(reg.exec(search));// []
        // console.log(reg.exec(search));// []
        // console.log(reg.exec(search));// []
        // console.log(reg.exec(search));// []
        // console.log(reg.exec(search));// null


        // var reg = /(\w+)=([^&]+)/g;
        // var result = null;
        // while (result = reg.exec(search)) {
            
        // }

        // search => "?user=zxczxc&pwd=123123&phone=17386141516&email=1272071496@qq.com"

        var reg = /(\w+)=([^&]+)/g; // user=a123123

        while (reg.exec(search)) {
            console.log(RegExp.$1,RegExp.$2);
            data[RegExp.$1] = decodeURIComponent(RegExp.$2);
        }

        console.log(data);


        // console.log(reg.exec(search));
        // console.log(reg.exec(search));
        // console.log(reg.exec(search));
        // console.log(reg.exec(search));
        // console.log(reg.exec(search));


    } else {
        if (confirm("您还没有注册,是否注册")) {
            location.href = "./register.html";
        }
    }
</script>
</html>